package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RiskEnergencyMgt;
import com.ruoyi.system.service.IRiskEnergencyMgtService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * RiskEnergencyMgtController
 */
@Anonymous
@RestController
@RequestMapping("/system/risk/mgt")
public class RiskEnergencyMgtController extends BaseController
{
    @Autowired
    private IRiskEnergencyMgtService riskEnergencyMgtService;

    /**
     * 查询应急与风险管理列表
     */
    //@PreAuthorize("@ss.hasPermi('system:mgt:list')")
    @GetMapping("/list")
    public TableDataInfo list(RiskEnergencyMgt riskEnergencyMgt)
    {
        startPage();
        List<RiskEnergencyMgt> list = riskEnergencyMgtService.selectRiskEnergencyMgtList(riskEnergencyMgt);
        return getDataTable(list);
    }

    /**
     * 导出应急与风险管理列表
     */
    //@PreAuthorize("@ss.hasPermi('system:mgt:export')")
    @Log(title = "应急与风险管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RiskEnergencyMgt riskEnergencyMgt)
    {
        List<RiskEnergencyMgt> list = riskEnergencyMgtService.selectRiskEnergencyMgtList(riskEnergencyMgt);
        ExcelUtil<RiskEnergencyMgt> util = new ExcelUtil<RiskEnergencyMgt>(RiskEnergencyMgt.class);
        util.exportExcel(response, list, "应急与风险管理数据");
    }

    /**
     * 获取应急与风险管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:mgt:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(riskEnergencyMgtService.selectRiskEnergencyMgtById(id));
    }

    /**
     * 新增应急与风险管理
     */
    //@PreAuthorize("@ss.hasPermi('system:mgt:add')")
    @Log(title = "应急与风险管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RiskEnergencyMgt riskEnergencyMgt)
    {
        return toAjax(riskEnergencyMgtService.insertRiskEnergencyMgt(riskEnergencyMgt));
    }

    /**
     * 修改应急与风险管理
     */
    //@PreAuthorize("@ss.hasPermi('system:mgt:edit')")
    @Log(title = "应急与风险管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RiskEnergencyMgt riskEnergencyMgt)
    {
        return toAjax(riskEnergencyMgtService.updateRiskEnergencyMgt(riskEnergencyMgt));
    }

    /**
     * 删除应急与风险管理
     */
    //@PreAuthorize("@ss.hasPermi('system:mgt:remove')")
    @Log(title = "应急与风险管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(riskEnergencyMgtService.deleteRiskEnergencyMgtByIds(ids));
    }
}
